package com.wenlin.myproduction.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.google.gson.annotations.Expose;

import java.io.Serializable;
import java.util.List;

public class QuestionEn implements Parcelable, Serializable {
    @Expose
    public int Score;
    @Expose
    public int QuestionId;
    @Expose
    public int QuestionTemple;
    @Expose
    public int QuestionType;
    @Expose
    public String QuestionTempleTips;
    @Expose
    public String QuestionTempleAudioUrl;
    @Expose
    public QuestionContent QuestionContent;
    @Expose
    public String QuestionTitle;
    @Expose
    public int AnswerTime;
    @Expose
    public String ReadContent;//短文内容
    @Expose
    public int ReadContentTime;//短文阅读时间
    @Expose
    public List<QuestionEn> QuestionList;//短文问题列表

    public boolean isReadContentQuestion;//是否短文问题 （用来判断是否要显示短文阅读）

    public int QuestionIndex;//问题第几题标识 短文不算 需要另外标识

    public boolean isShowResult;//是否显示答案 （默认不显示）

    public static class QuestionContent implements Parcelable, Serializable {
        @Expose
        public String Text;
        @Expose
        public String ImgUrl;
        @Expose
        public String AudioUrl;
        @Expose
        public String QuestionTitleRecording;//录音文字
        @Expose
        public String TeacherPic;//名师讲解
        @Expose
        public String TeacherExplanation;//名师讲解
        @Expose
        public List<Option> Options;
        @Expose
        public int AnswerType;//202012.4  1图片 2 文字 4 音频 其他组合为 2次方 枚举方法获得


        protected QuestionContent(Parcel in) {
            Text = in.readString();
            ImgUrl = in.readString();
            AudioUrl = in.readString();
            QuestionTitleRecording = in.readString();
            TeacherPic = in.readString();
            TeacherExplanation = in.readString();
            Options = in.createTypedArrayList(Option.CREATOR);
            AnswerType = in.readInt();
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeString(Text);
            dest.writeString(ImgUrl);
            dest.writeString(AudioUrl);
            dest.writeString(QuestionTitleRecording);
            dest.writeString(TeacherPic);
            dest.writeString(TeacherExplanation);
            dest.writeTypedList(Options);
            dest.writeInt(AnswerType);
        }

        @Override
        public int describeContents() {
            return 0;
        }

        public static final Creator<QuestionContent> CREATOR = new Creator<QuestionContent>() {
            @Override
            public QuestionContent createFromParcel(Parcel in) {
                return new QuestionContent(in);
            }

            @Override
            public QuestionContent[] newArray(int size) {
                return new QuestionContent[size];
            }
        };
    }

    public static class Option implements Parcelable, Serializable {
        @Expose
        public String Text;
        @Expose
        public String ImgUrl;
        @Expose
        public String AudioUrl;//选项音频地址
        @Expose
        public int AnswerFlag;//是否正确答案
        public boolean isCheck;


        protected Option(Parcel in) {
            Text = in.readString();
            ImgUrl = in.readString();
            AudioUrl = in.readString();
            AnswerFlag = in.readInt();
            isCheck = in.readByte() != 0;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeString(Text);
            dest.writeString(ImgUrl);
            dest.writeString(AudioUrl);
            dest.writeInt(AnswerFlag);
            dest.writeByte((byte) (isCheck ? 1 : 0));
        }

        @Override
        public int describeContents() {
            return 0;
        }

        public static final Creator<Option> CREATOR = new Creator<Option>() {
            @Override
            public Option createFromParcel(Parcel in) {
                return new Option(in);
            }

            @Override
            public Option[] newArray(int size) {
                return new Option[size];
            }
        };
    }

    public QuestionEn(){

    }

    protected QuestionEn(Parcel in) {
        Score = in.readInt();
        QuestionId = in.readInt();
        QuestionTemple = in.readInt();
        QuestionType = in.readInt();
        QuestionTempleTips = in.readString();
        QuestionTempleAudioUrl = in.readString();
        QuestionContent = in.readParcelable(QuestionEn.QuestionContent.class.getClassLoader());
        QuestionTitle = in.readString();
        AnswerTime = in.readInt();
        ReadContent = in.readString();
        ReadContentTime = in.readInt();
        QuestionList = in.createTypedArrayList(QuestionEn.CREATOR);
        isReadContentQuestion = in.readByte() != 0;
        QuestionIndex = in.readInt();
        isShowResult = in.readByte() != 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(Score);
        dest.writeInt(QuestionId);
        dest.writeInt(QuestionTemple);
        dest.writeInt(QuestionType);
        dest.writeString(QuestionTempleTips);
        dest.writeString(QuestionTempleAudioUrl);
        dest.writeParcelable(QuestionContent, flags);
        dest.writeString(QuestionTitle);
        dest.writeInt(AnswerTime);
        dest.writeString(ReadContent);
        dest.writeInt(ReadContentTime);
        dest.writeTypedList(QuestionList);
        dest.writeByte((byte) (isReadContentQuestion ? 1 : 0));
        dest.writeInt(QuestionIndex);
        dest.writeByte((byte) (isShowResult ? 1 : 0));
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<QuestionEn> CREATOR = new Creator<QuestionEn>() {
        @Override
        public QuestionEn createFromParcel(Parcel in) {
            return new QuestionEn(in);
        }

        @Override
        public QuestionEn[] newArray(int size) {
            return new QuestionEn[size];
        }
    };
}
